package com.shr.code_interview;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class Solution_45 {
    public String PrintMinNumber(int [] numbers) {
        Comparator<Integer> comparator = new Comparator<Integer>() {
			
			@Override
			public int compare(Integer o1, Integer o2) {
				long num1 = Long.parseLong(o1.toString() + o2.toString());
				long num2 = Long.parseLong(o2.toString() + o1.toString());
				return (int) (num1 - num2);
			}
		};
		
		List<Integer> list = new ArrayList<>();
		for(int i : numbers)
			list.add(i) ;
		Collections.sort(list, comparator);
		StringBuffer sb = new StringBuffer();
		for(int i : list){
			sb.append(i);
		}
		return sb.toString();
				
    }	
}
